package com.cssy.yd.logic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.yd.logic.dao.LogicSoCancelItemDAO;
import com.cssy.yd.logic.entity.LogicSoCancelItemDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2013-04-27
 */
public class LogicSoCancelItemDAOImpl extends SqlMapClientDaoSupport implements LogicSoCancelItemDAO {

    /**
     * 插入数据
     * @param logicSoCancelItemDO
     * @return 插入数据的主键
     */
    public String insertLogicSoCancelItemDO(LogicSoCancelItemDO logicSoCancelItemDO) {
        Object id = getSqlMapClientTemplate().insert("LogicSoCancelItem.insert", logicSoCancelItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicSoCancelItemDO
     * @return 查出的记录数
     */
    public Integer countLogicSoCancelItemDOByExample(LogicSoCancelItemDO logicSoCancelItemDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicSoCancelItem.countByDOExample", logicSoCancelItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicSoCancelItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicSoCancelItemDO(LogicSoCancelItemDO logicSoCancelItemDO) {
        int result = getSqlMapClientTemplate().update("LogicSoCancelItem.update", logicSoCancelItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicSoCancelItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicSoCancelItemDO> findListByExample(LogicSoCancelItemDO logicSoCancelItemDO) {
        List<LogicSoCancelItemDO> list = getSqlMapClientTemplate().queryForList("LogicSoCancelItem.findListByDO", logicSoCancelItemDO);
        return list;
    }

    /**
     * 根据主键获取logicSoCancelItemDO
     * @param id
     * @return logicSoCancelItemDO
     */
    public LogicSoCancelItemDO findLogicSoCancelItemDOByPrimaryKey(String id) {
        LogicSoCancelItemDO logicSoCancelItemDO = (LogicSoCancelItemDO) getSqlMapClientTemplate().queryForObject("LogicSoCancelItem.findByPrimaryKey", id);
        return logicSoCancelItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicSoCancelItemDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicSoCancelItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicSoCancelItemDO> find(SearchConditions scs) throws DataAccessException{
		
    	System.out.println(scs.getPrefix());
   		List<LogicSoCancelItemDO> list = getSqlMapClientTemplate().queryForList("LogicSoCancelItem_ex.find", scs);
   		   return list;
    	
    }
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicSoCancelItem_ex.count", scs);
  	      return count;
  	}
	
	/**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicSoCancelItemDO(String soid) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicSoCancelItem_ex.deleteByPrimaryKey", soid);
        return rows;
    }

}